<template>
  <div class="report-form-content">
    <el-form class="my-form" ref="obj" :model="obj" :rules="rules" label-position="right" label-width="auto" :disabled="oper === 'view'">
      <div class="report-form-content-title">
        <h1 style="font-weight: bold" v-if="!obj.id">新增二级项目</h1>
        <h1 style="font-weight: bold" v-else>编辑二级项目</h1>
        <div>
          <div class="tabs-list">
            <el-button v-show="checkAuthByCode('')" type="success" @click="handleStage('obj')">
              <svg-icon icon-class="save" />
              暂存
            </el-button>
            <el-button v-show="checkAuthByCode('')" type="primary" @click="handleSave('obj')">
              <svg-icon icon-class="save" />
              保存
            </el-button>
            <el-button v-show="checkAuthByCode('')" type="primary" @click="handleSubmit('obj')" v-if="obj.id">
              <svg-icon icon-class="submit" />
              提交审批
            </el-button>
          </div>
        </div>
      </div>
      <div>
        <label class="form-label form-label-1" style="color: #c45656;width: auto;">项目预算总金额：
          <span>{{parseInt(parseInt(obj.totalFund ? obj.totalFund : 0) + parseInt(obj.putinFund ? obj.putinFund : 0))}}元</span>
          &nbsp;(其中申请财政金额：{{obj.totalFund}}，社会投入资金：{{obj.putinFund}})
        </label>
      </div>
      <el-divider />
      <div>
        <el-tabs v-model="activeName" class="demo-tabs">
          <el-tab-pane label="基础信息" name="first"></el-tab-pane>
          <el-tab-pane label="分年度资金计划" name="second"></el-tab-pane>
          <el-tab-pane label="项目绩效信息" name="third"></el-tab-pane>
          <el-tab-pane label="附件信息" name="fourth"></el-tab-pane>
        </el-tabs>
        <div class="tabs-list" v-show="activeName === 'first'">
          <el-row :gutter="20">
            <el-col :sm="24" :lg="29" style="padding-left: 20px;">
              <div style="display: flex;align-items: center;justify-content: space-between;">
                <h2>项目基础信息</h2>
                <!--
                <label class="form-label form-label-1" style="color: #c45656;width: auto;">项目预算总金额：
                  <span>{{parseInt(parseInt(obj.totalFund ? obj.totalFund : 0) + parseInt(obj.putinFund ? obj.putinFund : 0))}}元</span>
                  (其中申请财政金额：{{obj.totalFund}}，社会投入资金：{{obj.putinFund}})
                </label>
                -->
              </div>
              <el-card class="update-log">
                <div class="report-form-list-content">
                  <el-form-item label="挂接一级项目" prop="projectOneId">
                    <el-input v-model="obj.projectOneName"
                              placeholder="请选择需要挂接的一级项目"
                              @focus="itemsVisible = true"
                              suffix-icon="Search"
                              readonly
                              style="width: 300px;" />
                  </el-form-item>
                </div>
                <div class="report-form-list-content">
                  <el-form-item label="二级项目编码" prop="code">
                    <el-input v-model="obj.code" placeholder="自动生成" disabled />
                  </el-form-item>
                  <el-form-item label="二级项目名称" prop="name">
                    <el-input v-model="obj.name" placeholder="请输入二级项目名称" />
                  </el-form-item>
                  <el-form-item label="存续状态" prop="viability">
                    <el-radio-group v-model="obj.viability" @change="viabilityChange">
                      <el-radio-button v-for="(item,index) in getDictList('BudgetProjectViability')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="项目起始年度" prop="startTime">
                    <el-date-picker v-model="obj.startTime" type="year" placeholder="请选择项目起始年度" value-format="YYYY" :disabled-date="disabledDateStart" @change="startTimeChange" />
                  </el-form-item>
                  <el-form-item label="项目终止年度" prop="endTime">
                    <el-date-picker v-model="obj.endTime" type="year" placeholder="请选择项目终止年度" value-format="YYYY" :disabled-date="disabledDateEnd" :disabled="isDisabledEndTime" @change="endTimeChange" />
                  </el-form-item>
                  <el-form-item label="项目来源" prop="source">
                    <el-radio-group v-model="obj.source">
                      <el-radio-button v-for="(item,index) in getDictList('BudgetProjectSource')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="申报属性" prop="attribute">
                    <el-radio-group v-model="obj.attribute">
                      <el-radio-button v-for="(item,index) in getDictList('BudgetProjectAttribute')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="申请财政金额" prop="totalFund">
                    <el-input-number v-model="obj.totalFund" placeholder="申请财政金额" :precision="2" disabled />
                  </el-form-item>
                  <el-form-item label="社会投入资金" prop="putinFund">
                    <el-input-number v-model="obj.putinFund" placeholder="请输入社会投入资金" :precision="2" />
                  </el-form-item>
                  <el-form-item label="当年资金" prop="currFund">
                    <el-input-number v-model="obj.currFund" placeholder="请输入当年资金" :precision="2" />
                  </el-form-item>
                  <el-form-item label="资金性质" prop="fundType">
                    <el-select v-model="obj.fundType" placeholder="请选择" clearable filterable>
                      <el-option v-for="item in getDictList('BudgetFundType')" :key="item.key" :label="`${item.key} - ${item.value}`" :value="item.key" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="用款单位" prop="useGovId">
                    <el-cascader v-model="obj.useGovId" :options="arrChangeTreeFn(governmentList)" :props="{label: 'governmentName', value: 'id', checkStrictly: true}" clearable />
                  </el-form-item>
                  <el-form-item label="申报单位" prop="applyGovId">
                    <el-cascader v-model="obj.applyGovId" :options="arrChangeTreeFn(governmentList)" :props="{label: 'governmentName', value: 'id', checkStrictly: true}" clearable />
                  </el-form-item>
                  <el-form-item label="上一年项目预算安排情况" prop="previousArrange">
                    <el-input-number v-model="obj.previousArrange" placeholder="请输入上一年项目预算安排情况" :precision="2" />
                  </el-form-item>
                  <el-form-item label="主管部门" prop="managerOrgId">
                    <selectBudgetCompetent v-model="obj.managerOrgId" keyName="id" keyShow="name" placeholder="主管部门" title="预算主管部门查询" @onchange="changeManagerOrgId" />
                  </el-form-item>
                  <el-form-item label="主管部门联系人" prop="managerName">
                    <el-input v-model="obj.managerName" placeholder="请输入主管部门联系人" />
                  </el-form-item>
                  <el-form-item label="主管部门联系电话" prop="managerUserContact">
                    <el-input v-model="obj.managerUserContact" placeholder="请输入主管部门项目联系电话" />
                  </el-form-item>
                  <el-form-item label="是否债券可用项目" prop="isDebenture">
                    <el-radio-group v-model="obj.isDebenture">
                      <el-radio-button v-for="(item,index) in getDictList('BudgetProjectDebenture')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="是否科研项目" prop="isScientific">
                    <el-radio-group v-model="obj.isScientific">
                      <el-radio-button v-for="(item,index) in getEnumList('CommonYesNo')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
                    </el-radio-group>
                  </el-form-item>
                </div>
                <div class="form-list-content">
                  <el-form-item label="项目实施单位" prop="workGovId">
                    <el-cascader v-model="obj.workGovId" :options="arrChangeTreeFn(governmentList)" :props="{label: 'governmentName', value: 'id', checkStrictly: true}" clearable />
                  </el-form-item>
                  <el-form-item label="项目负责人" prop="workUserId">
                    <User v-model="obj.workUserId" keyName="id" keyShow="name" placeholder="负责人" title="用户查询" />
                  </el-form-item>
                  <el-form-item label="项目负责联系电话" prop="workUserContact">
                    <el-input v-model="obj.workUserContact" placeholder="请输入项目负责联系电话" />
                  </el-form-item>
                </div>
                <el-form-item label="项目概述" prop="summarize">
                  <el-input v-model="obj.summarize" :rows="5" type="textarea" class="textarea-1" placeholder="请输入项目概述" />
                </el-form-item>
                <el-form-item label="设立依据及申报理由" prop="reason">
                  <el-input v-model="obj.reason" :rows="5" type="textarea" class="textarea-1" placeholder="请输入设立依据及申报理由" />
                </el-form-item>
                <div class="report-form-list-content">
                  <el-form-item label="是否基建项目" prop="isConstruction">
                    <el-radio-group v-model="obj.isConstruction">
                      <el-radio-button v-for="(item,index) in getEnumList('CommonYesNo')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
                    </el-radio-group>
                  </el-form-item>
                </div>
              </el-card>
              <el-card class="update-log" v-if="obj.isConstruction === '1'">
                <label class="form-label">基建类项目信息:</label>
                <div class="form-list-content">
                  <el-form-item label="基建立项情况" prop="constructionDesc">
                    <el-select v-model="obj.constructionDesc" class="m-2" placeholder="请选择" clearable filterable>
                      <el-option v-for="item in getDictList('BudgetProjectConstruction')" :key="item.key" :label="item.value" :value="item.key" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="是否代建项目" prop="isAgent">
                    <el-radio-group v-model="obj.isAgent" @change="obj.agentGovId = null">
                      <el-radio-button v-for="(item,index) in getEnumList('CommonYesNo')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="代建单位" prop="agentGovId" v-if="obj.isAgent === '1'">
                    <el-cascader v-model="obj.agentGovId" :options="arrChangeTreeFn(governmentList)" :props="{label: 'governmentName', value: 'id', checkStrictly: true}" clearable />
                  </el-form-item>
                </div>
              </el-card>
            </el-col>
          </el-row>
          <el-divider />
        </div>
        <div class="tabs-list" v-show="activeName === 'second'">
          <div class="" style="display: flex;align-items: center;">
            <h2>项目资金构成（单位: 元）</h2>
            <el-button type="primary" icon="Plus" style="margin-left:20px" @click="addItem">新增</el-button>
          </div>
          <div class="report-form-list-content" v-for="(item,index) in items" :key="index">
            <label class="form-label">项目资金构成{{ index + 1 }}:</label>
            <el-card class="update-log update-log-1">
              <div class="report-form-list-content">
                <el-form-item label="年度">
                  <el-date-picker v-model="item.year" type="year" placeholder="请选择年度" style="width: 166px;" value-format="YYYY" @change="buildYearsRefreshTotalFund" :disabled-date="disabledDate1" />
                </el-form-item>
                <el-form-item label="明细项目类别">
                  <el-cascader v-model="item.itemType" :props="{label: 'itemTypeName', value: 'id'}" :options="itemTypeList" @change="categoryChange($event,item,index)" />
                </el-form-item>
                <el-form-item label="开支范围">
                  <selectBudgetItemRange v-model="item.itemRange" keyName="id" keyShow="itemRangeName" placeholder="开支范围" title="开支范围查询" />
                </el-form-item>
                <el-form-item label="开支内容">
                  <el-input v-model="item.itemName" placeholder="请输入开支内容，最多输入100个字符" />
                </el-form-item>
                <el-form-item label="功能分类">
                  <el-select v-model="item.itemFunctionType" class="m-2" placeholder="请选择" clearable filterable>
                    <el-option v-for="item1 in getDictList('BudgetItemFunctionType')" :key="item1.key" :label="`${item1.key} - ${item1.value}`" :value="item1.key" />
                  </el-select>
                </el-form-item>
                <el-form-item label="经济分类">
                  <el-select v-model="item.itemEconomyType" class="m-2" placeholder="请选择" clearable filterable>
                    <el-option v-for="item1 in getDictList('BudgetItemEconomyType')" :key="item1.key" :label="`${item1.key} - ${item1.value}`" :value="item1.key" />
                  </el-select>
                </el-form-item>
                <el-form-item label="计量单位">
                  <el-input v-model="item.unit" placeholder="请输入计量单位，最多输入100个字符" />
                </el-form-item>
                <el-form-item label="单价/支出标准">
                  <el-input-number v-model="item.price" placeholder="请输入单价/支出标准" @change="buildYearsRefreshTotalFund" :precision="2" />
                </el-form-item>
                <el-form-item label="工作量">
                  <el-input-number v-model="item.num" placeholder="请输入工作量" @change="buildYearsRefreshTotalFund" :precision="2" />
                </el-form-item>
                <el-form-item label="测算依据及说明">
                  <el-input v-model="item.reason" placeholder="请输入测算依据及说明" />
                </el-form-item>
                <el-form-item label="按标准测算金额">
                  <el-input-number :value="item.price * item.num" disabled placeholder="按标准测算金额" :precision="2" />
                </el-form-item>
              </div>
              <div class="form-list-content-1">
                <el-form-item label="备注">
                  <el-input v-model="item.remark" :rows="4" :cols="100" type="textarea" class="textarea-1" placeholder="请输入备注，最多输入3000个字符" />
                </el-form-item>
                <div class="" style="width: 100%">
                  <el-button class="ico-list" icon="Edit" type="primary" @click="copyItem(item,index)">复制</el-button>
                  <el-button class="ico-list" icon="Delete" type="danger" v-if="index >= 1" @click="removeItem(index)">删除</el-button>
                </div>
              </div>
            </el-card>
          </div>
          <h2>分年度资金计划</h2>
          <el-card class="update-log">
            <div v-for="(item,index) in years" :key="index">
              <label class="form-label">{{item.year}}年度</label>
              <div class="report-form-list-content">
                <el-form-item label="单位申报数" prop="applyFund">
                  <el-input v-model="item.applyFund" placeholder="自动计算" disabled />
                </el-form-item>
                <el-form-item label="三保目录" prop="catalog">
                  <el-select v-model="item.thirdCatalog" class="m-2" placeholder="请选择三保目录" clearable filterable>
                    <el-option v-for="m in thirdCatalogList" :key="m.id" :label="`${m.thirdCode} - ${m.thirdName}`" :value="m.id" />
                  </el-select>
                </el-form-item>
                <el-form-item label="热点分类" prop="hot">
                  <selectBudgetHotCatalog v-model="item.hotCatalog" keyName="id" keyShow="hotName" placeholder="热点分类" title="热点分类查询" />
                </el-form-item>
              </div>
            </div>
          </el-card>
        </div>
        <div class="tabs-list" v-show="activeName === 'third'">
          <h3>绩效目标</h3>
          <el-card class="update-log">
            <el-form-item label="总体绩效目标" prop="targetAll">
              <el-input v-model="obj.targetAll" :rows="5" type="textarea" class="textarea-1" placeholder="请输入总体绩效目标" />
            </el-form-item>
            <el-form-item label="年度绩效目标" prop="targetCurrent">
              <el-input v-model="obj.targetCurrent" :rows="5" type="textarea" class="textarea-1" placeholder="请输入年度绩效目标" />
            </el-form-item>
          </el-card>
          <!-- <div class="add-indexs">
            <h3>总体绩效指标</h3>
            <el-button type="primary" icon="Plus">新增指标</el-button>
          </div>
          <el-card class="update-log">
            <el-table
                :data="kpiListAll"
                style="width: 100%; margin-bottom: 20px"
                row-key="id"
                class="indexsTabel"
                border
                default-expand-all
            >
              <el-table-column prop="kpiName" label="指标名称">
                <template v-slot="{row}">
                  <span v-if="row && row.level && row.level !== '3'">{{ row.kpiName }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="" label="指标名称">
                <template v-slot="{row}">
                  <el-form-item prop="kpiName" v-if="row && row.level && row.level === '3'">
                    <el-input v-model="row.kpiName" placeholder="请输入指标名称" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column prop="" label="指标解释">
                <template v-slot="{row}">
                  <el-form-item v-if="row.level === '3'" prop="kpiContent">
                    <el-input v-model="row.kpiContent" placeholder="请输入指标解释" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column prop="" label="指标值">
                <template v-slot="{row}">
                  <el-form-item v-if="row.level === '3'" prop="kpiValue" >
                    <el-input v-model="row.kpiValue" placeholder="请输入指标值" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column prop="" label="备注">
                <template v-slot="{row}">
                  <el-form-item v-if="row.level === '3'" prop="remark" >
                    <el-input v-model="row.remark" placeholder="请输入备注" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="160px" fixed="right">
                <template #default="scope">
                  <el-button type="primary" link @click="addKpiAll(scope.row)" v-if="scope.row.level === '2'">新建三级指标</el-button>
                  <el-button type="danger" link @click="deleteKpiAll(scope.row)" v-if="scope.row.level === '3'">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-card> -->
          <div class="add-indexs">
            <h3>本年度绩效指标</h3>
          </div>
          <el-card class="update-log">
            <el-table
                :data="kpiListCurrent"
                style="width: 100%; margin-bottom: 20px"
                row-key="id"
                class="indexsTabel"
                border
                default-expand-all
            >
              <el-table-column prop="kpiName" label="指标名称">
                <template v-slot="{row}">
                  <span v-if="row && row.level && row.level !== 3">{{ row.kpiName }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="" label="指标名称">
                <template v-slot="{row}">
                  <el-form-item prop="kpiName" v-if="row && row.level && row.level === 3">
                    <el-autocomplete v-model="row.kpiName"
                                     :fetch-suggestions="querySearch1"
                                     clearable
                                     value-key="name"
                                     placeholder="请输入/选择指标名称"
                                     @select="handleSelectKpi3($event,row)" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column prop="" label="指标解释">
                <template v-slot="{row}">
                  <el-form-item v-if="row.level === 3" prop="kpiContent">
                    <el-input v-model="row.kpiContent" placeholder="请输入指标解释" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column prop="" label="周期指标值">
                <template v-slot="{row}">
                  <el-form-item v-if="row.level === 3" prop="kpiValuePeriod">
                    <el-input v-model="row.kpiValuePeriod" placeholder="请输入周期指标值" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column prop="" label="年度指标值">
                <template v-slot="{row}">
                  <el-form-item v-if="row.level === 3" prop="kpiValue">
                    <el-input v-model="row.kpiValue" placeholder="请输入年度指标值" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column prop="" label="备注">
                <template v-slot="{row}">
                  <el-form-item v-if="row.level === 3" prop="remark" >
                    <el-input v-model="row.remark" placeholder="请输入备注" />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="160px" fixed="right">
                <template #default="scope">
                  <el-button type="primary" link @click="addKpiCurrent(scope.row)" v-if="scope.row.level === 2">新建三级指标</el-button>
                  <el-button type="danger" link @click="deleteKpiCurrent(scope.row)" v-if="scope.row.level === 3">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-card>
        </div>
        <div class="tabs-list" v-show="activeName === 'fourth'">
          <!-- <el-card class="update-log"></el-card> -->

          <!-- 附件信息 -->
          <div class="file-list-btn">
            <span class="file-list-btn-span">*请按要求上传项目政策依据、资金需求、立项论证情况、其他资料等资料</span>
            <div class="file-list-btns">
              <FileUpload :isShowTip="false" v-model="files" :isShowFileList="false" @uploadedSuccess="uploadedSuccessFn" />
              <!--
              <el-button type="primary" style="margin-left: 20px;">批量下载</el-button>
              -->
            </div>
          </div>
          <el-table
            :data="files"
            style="width: 100%; margin-top: 20px"
            row-key="id"
            border
            default-expand-all
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55" />
            <el-table-column label="附件类型">
              <template #default="scope">
                <el-form-item prop="fileType">
                  <el-select v-model="scope.row.fileType" placeholder="请选择附件类型" clearable filterable>
                    <el-option v-for="item in getDictList('BudgetProjectFileType')" :key="item.key" :label="`${item.key} - ${item.value}`" :value="item.key" />
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="original" label="附件名称" />
            <el-table-column align="center" label="操作" width="160px" fixed="right">
              <template #default="scope">
                <el-button type="primary" link @click="downloadFile(scope.row)">下载</el-button>
                <el-button type="primary" link @click="viewFile(scope.row)">预览</el-button>
                <el-button type="danger" link @click="removeFile(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </el-form>
  </div>
  <el-dialog v-model="dialogVisible" title="附件预览" width="70%" top="2vh">
    <attachmentPreview v-model:attachmentId="previewAttachmentId" />
    <div style="text-align:right;">
      <el-button type="info" icon="Close" @click="dialogVisible = false">关闭</el-button>
    </div>
  </el-dialog>
  <selectApprove v-model:itemsVisible="dialogApproveVisible" @close="dialogApproveVisible = false" :business="'1001'" :businessId="obj.id" @doSubmit="doSubmit" />
  <selectProjectOneList v-model:itemsVisible="itemsVisible" @close="itemsVisible = false" @projectOneSelect="changeProjectOne"></selectProjectOneList>
</template>

<script>
import baseConfig from '@/mixins/baseConfig'
import {doGet, doGetDownload, doPost} from '@/config/http'
import {customValidator, arrChangeTreeFn, notifySuccess, alertErrorMsg, objKeyBuild, getListPageSize, svc} from '@/config/common'
import attachmentPreview from '../../../../components/base/attachmentPreview.vue'
import selectProjectOneList from '@/views/components/budget/selectProjectOneList.vue'
import selectBudgetCompetent from "@/views/components/budget/selectBudgetCompetent.vue";
import selectApprove from "@/views/components/base/selectApprove.vue";
import User from "@/views/components/base/selectUser.vue";
import selectBudgetHotCatalog from "@/views/components/budget/selectBudgetHotCatalog.vue";
import selectBudgetItemRange from "@/views/components/budget/selectBudgetItemRange.vue";
import initListStore from '@/store/modules/initList'

const emptyObj = {
  projectOneId: null, // 一级项目ID
  projectOneName: '', // 一级项目名称
  code: null, // 项目编码
  name: null, // 项目名称
  viability: null, // 存续状态
  source: null, // 项目来源
  attribute: null, // 项目属性
  totalFund: 0, // 申请财政总额
  putinFund: 0, // 社会投入资金
  currFund: 0, // 当年资金
  useGovId: null, // 用款单位ID
  applyGovId: null, // 申报单位ID
  fundType: null, // 资金性质
  previousArrange: null, // 上一年项目预算安排情况
  managerOrgId: null, // 主管部门ID
  managerName: null, // 主管部门联系人ID
  managerUserContact: null, // 主管部门联系电话
  workGovId: null, // 项目实施单位ID
  workUserId: null, // 项目负责人ID
  workUserContact: null, // 项目负责人联系方式
  state: null, // 状态
  startTime: null, // 起始年度
  endTime: null, // 终止年度
  summarize: null, // 项目概述
  reason: null, // 设立依据及申报理由
  isDebenture: null, // 是否债券可用项目
  isScientific: null, // 是否科研项目
  isConstruction: null, // 是否基建项目
  constructionDesc: null, // 基建立项情况
  isAgent: null, // 是否代建项目
  agentGovId: null, // 代建单位ID
  isGovernmentPurchase: null, // 是否政府采购
  purchaseProject: null, // 采购项目
  purchaseKind: null, // 采购品目
  purchaseRequire: null, // 采购需求概况
  purchaseDate: null, // 预计采购时间
  purchaseAttr: null, // 资金性质
  purchaseFund: null, // 采购金额
  purchasePrice: null, // 单价
  purchaseNum: null, // 采购数量
  purchaseUnit: null, // 计量单位
  targetAll: null, // 项目绩效总目标
  targetCurrent: null, // 项目绩效本年度目标
  id: null,
  createBy: null,
  createTime: null,
  updateBy: null,
  updateTime: null,
  deleted: null,
  version: null,
}

const emptyItem = {
  year: '',
  itemType: null,
  itemRange: null,
  itemEconomyType: '',
  itemFunctionType: '',
  itemName: '',
  unit: '',
  price: 0,
  num: 0,
  according: '',
  remark: '',
}

const emptyYear = {
  year: '',
  applyFund: 0,
  approveFund: 0,
  budgetFund: 0,
  catalog: '',
  bringFund: 0,
  hot: '',
  according: '',
  remark: '',
}

const emptyKpi = {
  id: '',
  projectTwoId: null,
  performanceType: '1',
  level: 3,
  kpiCode: '',
  kpiName: '',
  kpiContent: '',
  kpiValue: '',
  remark: '',
  weight: null,
  parentId: null,
  kpiValuePeriod: ''
}

const emptyFile = {
  id: '',
  projectTwoId: null,
  attachmentType: '',
  attachmentId: '',
  attachmentName: '',
}


export default {
  name: 'projectTwoEditForm_nocache',
  mixins: [baseConfig],
  components: {
    selectBudgetItemRange,
    selectBudgetHotCatalog,
    User,
    selectApprove,
    selectBudgetCompetent,
    attachmentPreview,
    selectProjectOneList,
  },
  data() {
    return {
      svc: 'icims-api',
      obj: Object.assign({}, emptyObj),
      routes: [],
      oper: null,
      id: null,
      dialogVisible: false,
      dialogType: 'add',
      dialogTypeTitle: '新增',
      dialogApproveVisible: false,
      checkStrictly: false,
      radio1: '1',
      radio2: '已保存',
      isDisabledEndTime: false,
      fileData: '',
      defaultProps: {
        children: 'children',
        label: 'title'
      },
      activeName: 'first',
      items: [ Object.assign({}, emptyItem) ],
      years: [ Object.assign({}, emptyYear) ],
      kpis: [ Object.assign({}, emptyKpi) ],
      files: [],
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: false,
      hasChildren: false,
      children: [],
      catalogProjectList: [],
      kpiListAll: [],
      kpiListCurrent: [],
      selectionList: [],
      dialogFormVisible: false,
      itemsVisible: false,
      itemFiles: [],
      previewAttachmentId: '',
      dialogStatus: '',
      rules: {
        projectOneId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '一级项目ID', trigger: ['blur', 'change'] }],
        code: [{ required: false, validator: customValidator, min: 0, max: 50, label: '项目编码', trigger: ['blur', 'change'] }],
        name: [{ required: true, validator: customValidator, min: 0, max: 100, label: '项目名称', trigger: ['blur', 'change'] }],
        viability: [{ required: true, validator: customValidator, min: 0, max: 20, label: '存续状态', trigger: ['blur', 'change'] }],
        source: [{ required: true, validator: customValidator, min: 0, max: 20, label: '项目来源', trigger: ['blur', 'change'] }],
        attribute: [{ required: true, validator: customValidator, min: 0, max: 20, label: '项目属性', trigger: ['blur', 'change'] }],
        totalFund: [{ required: true, validator: customValidator, min: 0, max: 13, label: '申请财政总额', trigger: ['blur', 'change'] }],
        putinFund: [{ required: true, validator: customValidator, min: 0, max: 13, label: '社会投入资金', trigger: ['blur', 'change'] }],
        currFund: [{ required: true, validator: customValidator, min: 0, max: 13, label: '当年资金', trigger: ['blur', 'change'] }],
        useGovId: [{ required: true, validator: customValidator, min: 0, max: 20, label: '用款单位ID', trigger: ['blur', 'change'] }],
        applyGovId: [{ required: true, validator: customValidator, min: 0, max: 20, label: '申报单位ID', trigger: ['blur', 'change'] }],
        previousArrange: [{ required: true, validator: customValidator, min: 0, max: 200, label: '上一年项目预算安排情况', trigger: ['blur', 'change'] }],
        managerOrgId: [{ required: true, validator: customValidator, min: 0, max: 20, label: '主管部门', trigger: ['blur', 'change'] }],
        managerName: [{ required: false, validator: customValidator, min: 0, max: 20, label: '主管部门联系人ID', trigger: ['blur', 'change'] }],
        managerUserContact: [{ required: false, validator: customValidator, min: 0, max: 20, label: '主管部门联系电话', trigger: ['blur', 'change'] }],
        workGovId: [{ required: true, validator: customValidator, min: 0, max: 20, label: '项目实施单位ID', trigger: ['blur', 'change'] }],
        workUserId: [{ required: true, validator: customValidator, min: 0, max: 20, label: '项目负责人ID', trigger: ['blur', 'change'] }],
        workUserContact: [{ required: true, validator: customValidator, min: 0, max: 20, label: '项目负责人联系方式', trigger: ['blur', 'change'] }],
        state: [{ required: true, validator: customValidator, min: 0, max: 20, label: '状态', trigger: ['blur', 'change'] }],
        startTime: [{ required: true, validator: customValidator, min: 0, max: 4, label: '起始年度', trigger: ['blur', 'change'] }],
        endTime: [{ required: true, validator: customValidator, min: 0, max: 4, label: '终止年度', trigger: ['blur', 'change'] }],
        summarize: [{ required: true, validator: customValidator, min: 30, max: 3000, label: '项目概述', trigger: ['blur', 'change'] }],
        reason: [{ required: true, validator: customValidator, min: 30,  max: 3000, label: '设立依据及申报理由', trigger: ['blur', 'change'] }],
        isDebenture: [{ required: true, validator: customValidator, min: 0, max: 20, label: '是否债券可用项目', trigger: ['blur', 'change'] }],
        isScientific: [{ required: true, validator: customValidator, min: 0, max: 20, label: '是否科研项目', trigger: ['blur', 'change'] }],
        isConstruction: [{ required: true, validator: customValidator, min: 0, max: 20, label: '是否基建项目', trigger: ['blur', 'change'] }],
        constructionDesc: [{ required: true, validator: customValidator, min: 0, max: 20, label: '基建立项情况', trigger: ['blur', 'change'] }],
        isAgent: [{ required: true, validator: customValidator, min: 0, max: 20, label: '是否代建项目', trigger: ['blur', 'change'] }],
        agentGovId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '代建单位ID', trigger: ['blur', 'change'] }],
        isGovernmentPurchase: [{ required: false, validator: customValidator, min: 0, max: 20, label: '是否政府采购', trigger: ['blur', 'change'] }],
        purchaseProject: [{ required: false, validator: customValidator, min: 0, max: 100, label: '采购项目', trigger: ['blur', 'change'] }],
        purchaseKind: [{ required: false, validator: customValidator, min: 0, max: 100, label: '采购品目', trigger: ['blur', 'change'] }],
        purchaseRequire: [{ required: false, validator: customValidator, min: 0, max: 200, label: '采购需求概况', trigger: ['blur', 'change'] }],
        purchaseDate: [{ required: false, validator: customValidator, min: 0, max: 0, label: '预计采购时间', trigger: ['blur', 'change'] }],
        purchaseAttr: [{ required: false, validator: customValidator, min: 0, max: 200, label: '资金性质', trigger: ['blur', 'change'] }],
        purchaseFund: [{ required: false, validator: customValidator, min: 0, max: 13, label: '采购金额', trigger: ['blur', 'change'] }],
        purchasePrice: [{ required: false, validator: customValidator, min: 0, max: 13, label: '单价', trigger: ['blur', 'change'] }],
        purchaseNum: [{ required: false, validator: customValidator, min: 0, max: 5, label: '采购数量', trigger: ['blur', 'change'] }],
        purchaseUnit: [{ required: false, validator: customValidator, min: 0, max: 20, label: '计量单位', trigger: ['blur', 'change'] }],
        targetAll: [{ required: true, validator: customValidator, min: 30, max: 3000, label: '项目绩效总目标', trigger: ['blur', 'change'] }],
        targetCurrent: [{ required: true, validator: customValidator, min: 30, max: 3000, label: '项目绩效本年度目标', trigger: ['blur', 'change'] }],
      },
      inc: 100001,
      thirdCatalogList: initListStore().thirdCatalogList,
      hotCatalogList: initListStore().hotCatalogList,
      governmentList: initListStore().governmentList,
      organizationList: initListStore().organizationList,
      userList: initListStore().userList,
      itemTypeList: initListStore().itemTypeList,
      itemRangeAllList: initListStore().itemRangeAllList,
      kpi3List: initListStore().kpi3List,
      itemRangeList: [],
      managerUserList: [],
      approveList: [], //审批模版list
      isShowAttPreViewVisible: false,
      oFile: null,
      fileType: '',
      fileId: '',
      fileName: ''
    }
  },
  computed: {
    routesData() {
      return this.routes
    },
  },
  created() {
    // this.initCatalogProjectOneList()
    this.initObj()
    this.initList()
  },
  methods: {
    arrChangeTreeFn,
    async initCatalogProjectOneList() {
      this.catalogProjectList = []
      let p1 = doGet(this.svc, '/budget-catalog/page', {state:'1',pageSize: getListPageSize()}, false)
      let p2 = doGet(this.svc, '/budget-project-one/page', {pageSize: getListPageSize()}, false)
      let resArray = await Promise.all([p1, p2])
      let clist = resArray[0]['records']
      let p1list = resArray[1]['records']
      let p2list = resArray[1]['records']
      clist.forEach((curr) => {
        let cu = {}
        cu.value = curr.catalogCode
        cu.label = curr.catalogCode + ' - ' + curr.catalogName
        cu.children = []
        p1list.forEach((child1) => {
          if (child1.catalogId === curr.id && !child1.parentId) {
            child1.value = child1.id
            child1.label = child1.code + ' - ' + child1.name
            child1.children = []
            p2list.forEach((child2) => {
              if (child2.parentId === child1.id) {
                child2.value = child2.id
                child2.label = child2.code + ' - ' + child2.name
                child2.children = []
                child1.children.push(child2)
              }
            })
            cu.children.push(child1)
          }
        })
        this.catalogProjectList.push(cu)
      })
    },
    async initObj() {
      this.oper = this.$route.query.oper
      this.id = null
      if (this.$route.query.id) {
        this.id = this.$route.query.id
        let p1 = doGet(this.svc, '/budget-project-two/' + this.id, {})
        let p2 = doGet(this.svc, '/budget-project-two-item/listByField', {field: 'projectTwoId', values: this.id}, false)
        let p3 = doGet(this.svc, '/budget-project-two-year/listByField', {field: 'projectTwoId', values: this.id}, false)
        let p4 = doGet(this.svc, '/budget-project-two-kpi/listByField', {field: 'projectTwoId', values: this.id, sortField: 'weight', sortType: 'asc'}, false)
        let p5 = doGet(this.svc, '/budget-project-two-file/listByField', {field: 'projectTwoId', values: this.id}, false)
        let resArray = await Promise.all([p1, p2, p3, p4, p5])
        this.obj = resArray[0]
        if (this.obj.viability === '1') {
          this.obj.endTime = '2099'
          this.isDisabledEndTime = true
        } else {
          this.endTime = this.obj.endTime
        }
        this.items = resArray[1]
        this.years = resArray[2]
        this.kpis = resArray[3].reverse()
        this.files = resArray[4]
        this.files = this.files.map(item => {
          item.original = item.attachmentName
          return item
        })
        this.obj.totalFund = 0
        this.items.map(item => {
          this.obj.totalFund += item.price * item.num
        })
        await this.initKpiList()
        if (this.obj.projectOneId) {
          // 编辑
          doGet(this.svc, '/budget-project-one/' + this.obj.projectOneId, {}, false).then(res => {
            this.obj.projectOneName = res.name
          })
        }
      } else {
        // 新增
        this.obj = Object.assign({}, emptyObj)
        this.items = [ Object.assign({}, emptyItem) ]
        this.years = [ Object.assign({}, emptyYear) ]
        this.kpis = []
        this.files = []
        await this.initKpiList()
      }
    },
    async initKpiList() {
      if (this.$route.query.id && this.kpis.length > 0) {
        // let kpiListCurrent = this.kpis.filter(item => item.performanceType === '1').reverse()
        console.log('222',this.kpis)
        this.kpiListCurrent = arrChangeTreeFn(this.kpis.reverse())
        console.log('111',this.kpiListCurrent)
      } else {
        let p1 = doGet(this.svc, '/budget-kpi/page', {state:'1',pageSize: getListPageSize(), sortField: 'weight',sortType: 'asc'}, false)
        let resArray = await Promise.all([p1])
        let kpis = resArray[0]['records'].map(item => {
          item.performanceType = '1'
          item.kpiCode = item.code
          item.kpiName = item.name
          return item
        })
        let kpisCurrent = kpis.filter(item => item.level !== 3)
        this.kpiListCurrent = arrChangeTreeFn(kpisCurrent)
      }
    },
    async initList() {
      // 开支范围回显
      this.items.forEach((item,index) => {
        if (item.itemType) {
          this.categoryChange(item.itemType, item, index, 1)
        } else {
          this.itemRangeList[index] = this.itemRangeAllList
        }
      })
    },
    refreshManagerUserList(row) {
      this.managerUserList = []
      this.obj.managerName = ''
      this.obj.managerUserContact = ''
      doGet(this.svc, '/user/page', {pageSize: getListPageSize(),organizationId:row.managerOrgId}, false).then(res => {
        this.managerUserList = res['records']
      })
    },
    uploadedSuccessFn(file) {
      this.files.push(file)
    },
    changeProjectOne(data) {
      if (data.id !== undefined) {
        this.obj.projectOneId = data.id
        this.obj.projectOneName = data.name
        // this.obj.name = data.name
        // this.obj.viability = data.viability
        // this.obj.startTime = data.planStart
        // this.obj.endTime = data.planEnd
        // this.obj.totalFund = data.amount
        // this.obj.currFund = data.currentAmount
      } else {
        this.obj.projectOneId = null
      }
    },
    handleSelectionChange(data) {
      this.selectionList = data
    },
    buildObj() {
      let o = this.obj
      //items
      o.items = []
      o.items = this.items.map(item => {
        console.log('typeof(item.itemType)',typeof(item.itemType))
        if (item.itemType && typeof(item.itemType) === 'object' && item.itemType.length > 0) {
          console.log('item.itemType',item.itemType)
          item.itemType = item.itemType[1]
        }
        return item
      })

      o.useGovId = objKeyBuild(o.useGovId)
      o.applyGovId = objKeyBuild(o.applyGovId)
      o.workGovId = objKeyBuild(o.workGovId)
      o.agentGovId = objKeyBuild(o.agentGovId)

      o.years = []
      for (let idx in this.years) {
        o.years.push(this.years[idx])
      }
      //kpis
      o.kpis = []
      for (let i in this.kpiListAll) {
        let one = this.kpiListAll[i]
        o.kpis.push(one)
        for (let j in one.children) {
          let two = one.children[j]
          o.kpis.push(two)
          for (let k in two.children) {
            let three = two.children[k]
            o.kpis.push(three)
          }
        }
      }
      console.log('this.kpiListCurrent',this.kpiListCurrent)
      for (let i in this.kpiListCurrent) {
        let one = this.kpiListCurrent[i]
        o.kpis.push(one)
        for (let j in one.children) {
          let two = one.children[j]
          o.kpis.push(two)
          for (let k in two.children) {
            two.children[k].weight = k + 1
            let three = two.children[k]
            o.kpis.push(three)
          }
        }
      }
      //files
      o.files = this.files.map(item => {
        return {
          attachmentId: item.id,
          attachmentName: item.original,
          fileType: item.fileType
        }
      })
      // console.log('o.files----',o.files)
      return o
    },
    async doStage() {
      let o = this.buildObj()
      let res = await doPost(this.svc, '/customBudgetProject/stageBudgetProjectTwo', o, false);
      this.obj.id = res['id']
      this.obj.code = res['code']
      this.obj.version = res['version']
    },
    async handleStage() {
      await this.doStage()
      notifySuccess('暂存成功')
    },
    async handleSave(formName) {
      let v = await this.$refs[formName].validate().catch((err)=>{return err})
      if (v !== true) {
        alertErrorMsg('表单验证不通过，请检查数据。')
        return
      }
      let o = this.buildObj()
      await doPost(this.svc, '/customBudgetProject/saveBudgetProjectTwo', o, true);
      notifySuccess('保存成功')
      this.goTargetByName('projectTwo', {}, true)
    },
    async handleSubmit(formName) {
      let v = await this.$refs[formName].validate().catch((err)=>{return err})
      if (v !== true) {
        alertErrorMsg('表单验证不通过，请检查数据。')
        return
      }
      await this.doStage()
      this.dialogApproveVisible = true
    },
    async doSubmit(data) {
      let o = this.buildObj()
      o.approveId = data.approveId
      o.approveNodes = data.approveNodes
      await doPost(this.svc, '/customBudgetProject/submitBudgetProjectTwo', o, true);
      notifySuccess('提交成功')
      this.goTargetByName('projectTwo', {}, true)
    },
    addKpiAll(row) {
      let obj = Object.assign({}, emptyKpi)
      obj.parentId = row.id
      obj.id = this.inc++
      obj.performanceType = '0'
      if (row.children) {
        row.children.push(obj)
      } else {
        row.children = [obj]
      }
    },
    deleteKpiAll(row) {
      this.kpiListAll.forEach((one) => {
        if (one.performanceType === '0') {
          one.children.forEach((two) => {
            if (two.performanceType === '0' && two.level === 2 && two.id === row.parentId) {
              let index = two.children.findIndex(item1 => item1.id === row.id)
              two.children.splice(index, 1)
            }
          })
        }
      })
    },
    addKpiCurrent(row) {
      let obj = Object.assign({}, emptyKpi)
      obj.parentId = row.id
      obj.id = this.inc++
      obj.performanceType = '1'
      if (row.children) {
        row.children.push(obj)
      } else {
        row.children = [obj]
      }
    },
    deleteKpiCurrent(row) {
      this.kpiListCurrent.forEach((one) => {
        console.log('one',one)
        if (one.performanceType === '1') {
          console.log('11111111111')
          one.children.forEach((two) => {
            if (two.performanceType === '1' && two.level === 2 && two.id === row.parentId) {
              console.log('11111111111')
              let index = two.children.findIndex(item1 => item1.id === row.id)
              two.children.splice(index, 1)
            }
          })
        }
      })
    },
    getTreeTableParentRow(baseRow, row) {
      let prow = null;
      let children = baseRow.children;
      if (children && children.length > 0) {
        children.forEach((item) => {
          if (row.parentId === item.id) {
            prow = item;
          } else {
            prow = this.getTreeTableParentRow(item, row);
          }
        });
      }
      if (prow) {
        return prow
      }
    },
    // 新增项目资金构成
    addItem() {
      let item = Object.assign({}, emptyItem)
      this.items.push(item)
      this.buildYearsRefreshTotalFund()
    },
    copyItem(item,index) {
      let o = Object.assign({}, item)
      console.log('o----',o)
      this.items.splice(index, 0, o)
      // 开支范围回显
      if (o.itemType) {
        this.categoryChange(o.itemType, o, index + 1, 1)
      } else {
        this.itemRangeList[index + 1] = this.itemRangeAllList
      }
      this.buildYearsRefreshTotalFund()
    },
    // 删除项目资金构成
    removeItem(index) {
      this.items.splice(index, 1)
      this.buildYearsRefreshTotalFund()
    },
    buildYearsRefreshTotalFund() {
      this.years = []
      this.obj.totalFund = 0
      for (let idx in this.items) {
        let item = this.items[idx]
        if (!item.year)
          continue
        let ye = Object.assign({}, emptyYear)
        ye.year = item.year
        ye.applyFund = item.price * item.num
        this.obj.totalFund += item.price * item.num
        let found = false
        for (let k in this.years) {
          if (this.years[k].year === ye.year) {
            this.years[k].applyFund += item.price * item.num
            found = true
          }
        }
        if (!found)
          this.years.push(ye)
      }
    },
    querySearch1(queryString, cb) {
      const results = queryString
        ? this.kpi3List.filter(item => item.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
        : this.kpi3List

        console.log('results==========',results)
      // call callback function to return suggestions
      cb(results)
    },
    handleSelectKpi3(val,row) {
    },
    handlePreview(data) {
      console.log(data)
    },
    beforeRemove(data) {
      console.log(data)
    },
    handleRemove(data) {
      console.log(data)
    },
    handleExceed(data) {
      console.log(data)
    },
    downloadFile(row) {
      doGetDownload(svc, '/customAttachment/download/' + row.attachmentId, {})
    },
    viewFile(row) {
      this.dialogVisible = true
      setTimeout(() => {
        this.previewAttachmentId = row.attachmentId
      },200)
    },
    removeFile(scope) {
      this.files.splice(scope.$index, 1)
    },
    viabilityChange(val) {
      console.log('val-----',val)
      if (val === '1') {
        this.obj.endTime = '2099'
        this.isDisabledEndTime = true
      } else {
        this.isDisabledEndTime = false
        this.obj.endTime = this.endTime
      }
    },
    startTimeChange(val) {
      // this.endTime = val
      this.items = []
      if (this.obj.viability === '1') {
        let itm  = {
            year: '' + parseInt(this.obj.startTime),
            itemType: null,
            itemRange: null,
            itemName: '',
            unit: '',
            price: 0,
            num: 0,
            according: '',
            remark: '',
          }
          this.items.push(itm)
          this.buildYearsRefreshTotalFund()
      } else {
        if (this.obj.endTime && parseInt(this.obj.endTime) > parseInt(this.obj.startTime)) {
          let yearsNum = parseInt(this.obj.endTime) -  parseInt(this.obj.startTime)
          for(let i = 0; i < yearsNum + 1; i++) {
            let itm  = {
              year: '' + parseInt(parseInt(this.obj.startTime) + i),
              itemType: null,
              itemRange: null,
              itemName: '',
              unit: '',
              price: 0,
              num: 0,
              according: '',
              remark: '',
            }
            this.items.push(itm)
          }
          console.log('this.items----',this.items)
          this.buildYearsRefreshTotalFund()
        }
      }
    },
    endTimeChange(val) {
      this.endTime = val
      this.items = []
      if (this.obj.startTime && parseInt(this.obj.endTime) > parseInt(this.obj.startTime) && this.obj.viability === '2') {
        let yearsNum = parseInt(this.obj.endTime) -  parseInt(this.obj.startTime)
        for(let i = 0; i < yearsNum + 1; i++) {
          let itm  = {
            year: '' + parseInt(parseInt(this.obj.startTime) + i),
            itemType: null,
            itemRange: null,
            itemName: '',
            unit: '',
            price: 0,
            num: 0,
            according: '',
            remark: '',
          }
          this.items.push(itm)
        }
        console.log('this.items----',this.items)
        this.buildYearsRefreshTotalFund()
      } else {
        if (this.obj.startTime) {
          let itm  = {
            year: '' + parseInt(this.obj.startTime),
            itemType: null,
            itemRange: null,
            itemName: '',
            unit: '',
            price: 0,
            num: 0,
            according: '',
            remark: '',
          }
          this.items.push(itm)
          this.buildYearsRefreshTotalFund()
        }
      }
    },
    disabledDate1(data) {
      return  parseInt(this.obj.startTime) > data.getFullYear() || parseInt(this.obj.endTime) < data.getFullYear()
    },
    disabledDateStart(data) {
      return data.getFullYear() < new Date().getFullYear()
    },
    disabledDateEnd(data) {
      if (this.obj.startTime) {
        return parseInt(this.obj.startTime) > data.getFullYear()
      } else {
        return data.getFullYear() < new Date().getFullYear()
      }
    },
    categoryChange(val, item, index, type) {
      let id = typeof(val) === 'object' ? val[1] : val
      if (!type) {
        item.itemRange = typeof(val) === 'object' ? null : item.itemRange
      }
      doGet(this.svc, '/budget-item-type-range/listByField', {field: 'itemTypeId', values: id}, false).then(res => {
        if (res?.length > 0) {
          let ids = []
          res?.map(item => {
            ids.push(item.itemRangeId)
          })
          doGet(this.svc, '/budget-item-range/ids', {ids: ids.join(',')}, false).then(r => {
            this.itemRangeList[index] = r
          })
        }
      })
    },
    changeManagerOrgId(o) {
      this.obj.managerName = o.contact
      this.obj.managerUserContact = o.telephone
    },
  }
}
</script>
<style scoped>
.report-form-content-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.file-list-btn {
  display: flex;
  align-items: center;
  justify-content: space-between
}
.form-label {
  display: inline-flex;
  justify-content: flex-end;
  align-items: flex-start;
  flex: 0 0 auto;
  font-size: 16px;
  color: #337ecc;
  height: 32px;
  line-height: 32px;
  padding: 0 12px 0 0;
  box-sizing: border-box;
  width: 200px;
  font-weight: bold;
}
.update-log {
  width: 100%;
  margin-bottom: 30px;
}
.update-log-1 {
  margin-top: 0;
}
.add-indexs {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.file-list-btns {
  display: flex;
  align-items: center;
}
.file-list-btn-span {
  color: #F56C6C;
  font-size: 12px;
}
.form-label-1 {
  width: 18.75rem;
  justify-content: flex-start;
  margin-left: 1.375rem;
  color: #c45656;
}
.form-label-1 span {
  font-size: 1.25rem;
}
</style>
